/**
 * 
 */
package durak.common.model;

import java.io.Serializable;

/**
 * @authors Miri and Alex DONE!!!
 * 
 */
public class Card implements Serializable {

	private static final long serialVersionUID = -5456433904396544207L;

	public enum Rank {
		DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
	}

	public enum Suit {
		CLUBS, DIAMONDS, HEARTS, SPADES
	}

	private final Rank rank;
	private final Suit suit;

	public Card(Rank rank, Suit suit) {
		this.rank = rank;
		this.suit = suit;
	}

	public String toString() {
		return rank + " of " + suit;
	}
	
	public String toFileName() {
		return rank + "_" + suit;
	}

	public Rank getRank() {
		return this.rank;
	}

	public Suit getSuit() {
		return this.suit;
	}

	// shows the card suit and rank
	public void showCard() {
	};
	
	public boolean equals(Object otherCard) {
		if ( this == otherCard ) return true;
		if ( !(otherCard instanceof Card) ) return false;
		Card cardToCompare = (Card) otherCard;
		return (this.rank == cardToCompare.rank) && (this.suit == cardToCompare.suit);
	}
	
	public int hashCode() {
		int hash = 1604;
		hash = this.rank.ordinal() + 7*hash;
		hash = this.suit.ordinal() + 7*hash;
		return hash;
	}
}
